#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>



int main()
{
   int fd = open("log.txt", O_CREAT | O_WRONLY | O_TRUNC, 0666);
   if(fd < 0) exit(1);
   int cnt = 1;
  // const char* msg = "hello world! ";
  // while(cnt--)
  // {
  //    write(fd, msg, strlen(msg));
  // }
  int a = 1234567;
  while(cnt--)
  {
    //将整数当字符写入文件
    char buff[28];
    snprintf(buff, sizeof(buff), "%d", a);
    write(fd, buff, strlen(buff));
  }

   close(fd);
   return 0;
}
